import { Skin1CellRenderer } from "../common/item/Skin1CellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { IntimateHeartShaped } from "../friends/item/IntimateHeartShaped";
import { GTextFormat } from "../../../common/GTextFormat";
import { FriendInfo } from "../../model/FriendInfo";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { AvatarInfo } from "../../resource/info/AvatarInfo";
import { AvatarType } from "../../resource/info/AvatarType";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { ColorConfig } from "../../resource/ColorConfig";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class CountryFriendCellRenderer
    
    export  class CountryFriendCellRenderer extends Skin1CellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            ObjCreate.createBg(0, 28, 400, 2, this, ImagesConst.SplitLine);
            this._headImage = new Object /* flash.display.Bitmap */();
            this._headImage.width = 20;
            this._headImage.height = 20;
            this._headImage.x = 3;
            this._headImage.y = 5;
            this.addChild(this._headImage);
            this._textName = ObjCreate.createGTextField("", 28, 5, 90, 20, this);
            this._textCamp = ObjCreate.createGTextField("", 115, 5, 40, 20, this);
            this._levelTxt = ObjCreate.createGTextField("", 185, 5, 30, 20, this);
            this._careerTxt = ObjCreate.createGTextField("", 220, 5, 50, 20, this);
            this._intimateHeartShaped = new IntimateHeartShaped();
            this._intimateHeartShaped.x = 280;
            this._intimateHeartShaped.y = 10;
            this._intimateHeartShaped.mouseChildren = false;
            this.addChild(this._intimateHeartShaped);
            return;
        }

        protected /* override */ initMouseEnabled(): void
        {
            this.mouseChildren = false;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var arg0: Object;
            var imgName: string;
            var loadCompl: Function;
            var campId: int;
            var campColor: uint;
            var campTf: GTextFormat;

            var loc1;
            imgName = null;
            campId = 0;
            campColor = 0;
            campTf = null;
            arg0 = arg1;
            super.data = arg0;
            this._friendInfo = arg0 as FriendInfo;
            if (this._friendInfo) 
            {
                loadCompl = (arg1: ImageInfo): void
                {
                    _headImage.bitmapData = arg1.bitmapData;
                    _headImage.width = 20;
                    _headImage.height = 20;
                    _headImage.y = 7;
                    return;
                }
                imgName = AvatarInfo.getPlayerAvatarName(this._friendInfo.friendPlayerInfo.camp, this._friendInfo.friendPlayerInfo.sex, AvatarType.FRIEND, this._friendInfo.friendPlayerInfo.avatarId);
                if (this._friendInfo.friendPlayerInfo.photo) 
                {
                    AvatarInfo.getUpdateAvatar(this._friendInfo.friendPlayerInfo.entityId, AvatarType.UPLOADSMALL, loadCompl);
                }
                else 
                {
                    LoaderManager.instance.load(imgName, loadCompl);
                }
                campId = this._friendInfo.friendPlayerInfo.camp;
                campColor = ColorConfig.instance.getCountryColor(campId).intColor;
                campTf = new GTextFormat("", 12, campColor, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
                this._textName.text = this._friendInfo.friendPlayerInfo.playerName;
                this._textCamp.text = this._friendInfo.friendPlayerInfo.campName;
                this._textCamp.setTextFormat(campTf);
                this._levelTxt.text = this._friendInfo.friendPlayerInfo.level + "";
                this._careerTxt.text = this._friendInfo.friendPlayerInfo.career;
                this._intimateHeartShaped.intimate = this._friendInfo.intimate;
            }
            else 
            {
                this._headImage.bitmapData = null;
                this._textName.text = "";
                this._textCamp.text = "";
                this._levelTxt.text = "";
                this._careerTxt.text = "";
                this._intimateHeartShaped.intimate = 0;
            }
            return;
        }

        /* internal */ /* var */_headImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_textName: GTextFiled;

        /* internal */ /* var */_textCamp: GTextFiled;

        /* internal */ /* var */_levelTxt: GTextFiled;

        /* internal */ /* var */_careerTxt: GTextFiled;

        /* internal */ /* var */_intimateHeartShaped: IntimateHeartShaped;

        protected /* var */_friendInfo: FriendInfo;
    }
